//
//  StyleView.m
//  BasketballClub
//
//  Created by 孙鸿吉 on 16/1/18.
//  Copyright © 2016年 孙鸿吉. All rights reserved.
//

#import "StyleView.h"

@implementation StyleView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self allViews];
    }
    return self;
}
- (void)allViews
{
    self.navigationView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64 * LAYOUT_SIZE_HEIGHT)];
    self.navigationView.backgroundColor = ColorHex(0x0d1c38);
    [self addSubview:self.navigationView];
    
    self.title = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2 - (40 * LAYOUT_SIZE), 29 * LAYOUT_SIZE_HEIGHT, 80* LAYOUT_SIZE, 26 * LAYOUT_SIZE_HEIGHT)];
    self.title.text = @"个人设置";
    self.title.textAlignment = 1;
    self.title.textColor = [UIColor yellowColor];
    self.title.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    [self.navigationView addSubview:self.title];
    
    //取消按钮
    self.cancleButton = [[UIButton alloc]initWithFrame:CGRectMake(10 * LAYOUT_SIZE, 29 * LAYOUT_SIZE_HEIGHT, 50 * LAYOUT_SIZE, 26 * LAYOUT_SIZE_HEIGHT)];
    [self.cancleButton setImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
    [self.navigationView addSubview:self.cancleButton];
    
    //
    self.nickNameView = [[UIView alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 100 * LAYOUT_SIZE_HEIGHT, SCREEN_WIDTH - 40 * LAYOUT_SIZE, 40 * LAYOUT_SIZE_HEIGHT)];
    self.nickNameView.layer.masksToBounds = YES;
    self.nickNameView.layer.cornerRadius = 8;
    self.nickNameView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.nickNameView];
    
    self.nickNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(5 * LAYOUT_SIZE, 5 * LAYOUT_SIZE_HEIGHT, 60 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    self.nickNameLabel.text = @"昵称";
    self.nickNameLabel.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    [self.nickNameView addSubview:self.nickNameLabel];
    
    self.styleTextView = [[UIView alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 160 * LAYOUT_SIZE_HEIGHT, SCREEN_WIDTH - 40 * LAYOUT_SIZE, 40 * LAYOUT_SIZE_HEIGHT)];
    self.styleTextView.layer.masksToBounds = YES;
    self.styleTextView.layer.cornerRadius = 8;
    self.styleTextView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.styleTextView];
    
    self.styleTextLabel = [[UILabel alloc]initWithFrame:CGRectMake(5 * LAYOUT_SIZE, 5 * LAYOUT_SIZE_HEIGHT, 100 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    self.styleTextLabel.text = @"个性签名";
    self.styleTextLabel.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    [self.styleTextView addSubview:self.styleTextLabel];
    
    self.changePWDView = [[UIView alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 220 * LAYOUT_SIZE_HEIGHT, SCREEN_WIDTH - 40 * LAYOUT_SIZE, 40 * LAYOUT_SIZE_HEIGHT)];
    self.changePWDView.layer.masksToBounds = YES;
    self.changePWDView.layer.cornerRadius = 8;
    self.changePWDView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.changePWDView];
    
    self.changePWDLabel = [[UILabel alloc]initWithFrame:CGRectMake(5 * LAYOUT_SIZE, 5 * LAYOUT_SIZE_HEIGHT, 100 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    self.changePWDLabel.text = @"修改密码";
    self.changePWDLabel.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    [self.changePWDView addSubview:self.changePWDLabel];
    
    self.logoutButton = [[UIButton alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 300 * LAYOUT_SIZE_HEIGHT, SCREEN_WIDTH - 40 * LAYOUT_SIZE, 40 * LAYOUT_SIZE_HEIGHT)];
    [self.logoutButton setTitle:@"退出登录" forState:UIControlStateNormal];
    [self.logoutButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.logoutButton.titleLabel.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    self.logoutButton.backgroundColor = [UIColor whiteColor];
    self.logoutButton.layer.masksToBounds = YES;
    self.logoutButton.layer.cornerRadius = 8;
    [self addSubview:self.logoutButton];
    //昵称编辑界面
    [self pushNickNameView];
    //个性签名编辑界面
    [self pushStyleView];
    //修改密码编辑界面
    [self pushChangePasswordView];

    
}
- (void)pushNickNameView
{
    self.nickNameBackView = [[UIView alloc]initWithFrame:CGRectMake(-320 * LAYOUT_SIZE, (SCREEN_HEIGHT - 200 * LAYOUT_SIZE_HEIGHT)/2, 320 * LAYOUT_SIZE, 200 * LAYOUT_SIZE_HEIGHT)];
    self.nickNameBackView.backgroundColor = ColorHex(0x0d1c38);
    self.nickNameBackView.layer.masksToBounds = YES;
    self.nickNameBackView.layer.cornerRadius = 8;
    [self addSubview:self.nickNameBackView];
    
    self.titleOfNickName = [[UILabel alloc]initWithFrame:CGRectMake(110 * LAYOUT_SIZE, 20 * LAYOUT_SIZE_HEIGHT, 100 * LAYOUT_SIZE, 25 * LAYOUT_SIZE_HEIGHT)];
    self.titleOfNickName.text = @"设置昵称";
    self.titleOfNickName.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    self.titleOfNickName.textAlignment = 1;
    self.titleOfNickName.textColor = [UIColor yellowColor];
    [self.nickNameBackView addSubview:self.titleOfNickName];
    
    self.nickNameImageView = [[UIImageView alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 65 * LAYOUT_SIZE_HEIGHT, 280 * LAYOUT_SIZE, 40 * LAYOUT_SIZE_HEIGHT)];
    self.nickNameImageView.image = [UIImage imageNamed:@"phoneNumberBackGroundInput@2x"];
    [self.nickNameBackView addSubview:self.nickNameImageView];
    
    
    self.nickNameTF = [[UITextField alloc]initWithFrame:CGRectMake(25 * LAYOUT_SIZE, 70 * LAYOUT_SIZE_HEIGHT, 270 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    self.nickNameTF.placeholder = @"请输入昵称";
    [self.nickNameTF setValue:[UIFont systemFontOfSize:16 * LAYOUT_SIZE] forKeyPath:@"_placeholderLabel.font"];
    [self.nickNameTF setValue:ColorHexA(0xFFFFE0, 0.7) forKeyPath:@"_placeholderLabel.textColor"];
    [self.nickNameBackView addSubview:self.nickNameTF];
    
    self.cancleButton1 = [[UIButton alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 125 * LAYOUT_SIZE_HEIGHT, 130 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    [self.cancleButton1 setTitle:@"取消" forState:UIControlStateNormal];
    self.cancleButton1.backgroundColor = ColorHex(0x90EE90);
    self.cancleButton1.layer.masksToBounds = YES;
    self.cancleButton1.layer.cornerRadius = 8;
    self.cancleButton1.titleLabel.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    [self.nickNameBackView addSubview:self.cancleButton1];
    
    self.saveButton1 = [[UIButton alloc]initWithFrame:CGRectMake(170 * LAYOUT_SIZE, 125 * LAYOUT_SIZE_HEIGHT, 130 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    [self.saveButton1 setTitle:@"保存" forState:UIControlStateNormal];
    self.saveButton1.backgroundColor = ColorHex(0x90EE90);
    self.saveButton1.layer.masksToBounds = YES;
    self.saveButton1.layer.cornerRadius = 8;
    self.saveButton1.titleLabel.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    [self.nickNameBackView addSubview:self.saveButton1];
}


- (void)pushStyleView
{
    self.styleBackView = [[UIView alloc]initWithFrame:CGRectMake(47 * LAYOUT_SIZE, SCREEN_HEIGHT, 320 * LAYOUT_SIZE, 200 * LAYOUT_SIZE_HEIGHT)];
    self.styleBackView.backgroundColor = ColorHex(0x0d1c38);
    self.styleBackView.layer.masksToBounds = YES;
    self.styleBackView.layer.cornerRadius = 8;
    [self addSubview:self.styleBackView];
    
    self.styleOfText = [[UILabel alloc]initWithFrame:CGRectMake(110 * LAYOUT_SIZE, 20 * LAYOUT_SIZE_HEIGHT, 100 * LAYOUT_SIZE, 25 * LAYOUT_SIZE_HEIGHT)];
    self.styleOfText.text = @"个性签名";
    self.styleOfText.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    self.styleOfText.textAlignment = 1;
    self.styleOfText.textColor = [UIColor yellowColor];
    [self.styleBackView addSubview:self.styleOfText];
    
    self.styleImageView = [[UIImageView alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 65 * LAYOUT_SIZE_HEIGHT, 280 * LAYOUT_SIZE, 40 * LAYOUT_SIZE_HEIGHT)];
    self.styleImageView.image = [UIImage imageNamed:@"phoneNumberBackGroundInput@2x"];
    [self.styleBackView addSubview:self.styleImageView];
    
    
    self.styleTF = [[UITextField alloc]initWithFrame:CGRectMake(25 * LAYOUT_SIZE, 70 * LAYOUT_SIZE_HEIGHT, 270 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    self.styleTF.placeholder = @"请输入签名";
    [self.styleTF setValue:[UIFont systemFontOfSize:16 * LAYOUT_SIZE] forKeyPath:@"_placeholderLabel.font"];
    [self.styleTF setValue:ColorHexA(0xFFFFE0, 0.7) forKeyPath:@"_placeholderLabel.textColor"];
    [self.styleBackView addSubview:self.styleTF];
    
    self.cancleButton2 = [[UIButton alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 125 * LAYOUT_SIZE_HEIGHT, 130 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    [self.cancleButton2 setTitle:@"取消" forState:UIControlStateNormal];
    self.cancleButton2.backgroundColor = ColorHex(0x90EE90);
    self.cancleButton2.layer.masksToBounds = YES;
    self.cancleButton2.layer.cornerRadius = 8;
    self.cancleButton2.titleLabel.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    [self.styleBackView addSubview:self.cancleButton2];
    
    self.saveButton2 = [[UIButton alloc]initWithFrame:CGRectMake(170 * LAYOUT_SIZE, 125 * LAYOUT_SIZE_HEIGHT, 130 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    [self.saveButton2 setTitle:@"保存" forState:UIControlStateNormal];
    self.saveButton2.backgroundColor = ColorHex(0x90EE90);
    self.saveButton2.layer.masksToBounds = YES;
    self.saveButton2.layer.cornerRadius = 8;
    self.saveButton2.titleLabel.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    [self.styleBackView addSubview:self.saveButton2];
}


- (void)pushChangePasswordView
{
    self.changeBackView = [[UIView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH, (SCREEN_HEIGHT - 320 * LAYOUT_SIZE_HEIGHT)/2, 320 * LAYOUT_SIZE, 270 * LAYOUT_SIZE_HEIGHT)];
    self.changeBackView.backgroundColor = ColorHex(0x0d1c38);
    self.changeBackView.layer.masksToBounds = YES;
    self.changeBackView.layer.cornerRadius = 8;
    [self addSubview:self.changeBackView];
    
    self.changeLabel = [[UILabel alloc]initWithFrame:CGRectMake(110 * LAYOUT_SIZE, 20 * LAYOUT_SIZE_HEIGHT, 100 * LAYOUT_SIZE, 25 * LAYOUT_SIZE_HEIGHT)];
    self.changeLabel.text = @"修改密码";
    self.changeLabel.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    self.changeLabel.textAlignment = 1;
    self.changeLabel.textColor = [UIColor yellowColor];
    [self.changeBackView addSubview:self.changeLabel];
    
    self.changeImageView = [[UIImageView alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 65 * LAYOUT_SIZE_HEIGHT, 260 * LAYOUT_SIZE, 40 * LAYOUT_SIZE_HEIGHT)];
    self.changeImageView.image = [UIImage imageNamed:@"phoneNumberBackGroundInput@2x"];
    [self.changeBackView addSubview:self.changeImageView];

    self.changeTF = [[UITextField alloc]initWithFrame:CGRectMake(25 * LAYOUT_SIZE, 70 * LAYOUT_SIZE_HEIGHT, 250 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    self.changeTF.placeholder = @"当前密码";
    self.changeTF.secureTextEntry = YES;
    self.changeTF.clearButtonMode = 3;
    [self.changeTF setValue:[UIFont systemFontOfSize:16 * LAYOUT_SIZE] forKeyPath:@"_placeholderLabel.font"];
    [self.changeTF setValue:ColorHexA(0xFFFFE0, 0.7) forKeyPath:@"_placeholderLabel.textColor"];
    [self.changeBackView addSubview:self.changeTF];
    
    self.neImageView = [[UIImageView alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 115 * LAYOUT_SIZE_HEIGHT, 260 * LAYOUT_SIZE, 40 * LAYOUT_SIZE_HEIGHT)];
    self.neImageView.image = [UIImage imageNamed:@"phoneNumberBackGroundInput@2x"];
    [self.changeBackView addSubview:self.neImageView];
    
    self.nePasswordTF = [[UITextField alloc]initWithFrame:CGRectMake(25 * LAYOUT_SIZE, 120 * LAYOUT_SIZE_HEIGHT, 250 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    self.nePasswordTF.placeholder = @"新密码";
    self.nePasswordTF.secureTextEntry = YES;
    self.nePasswordTF.clearButtonMode = 3;
    [self.nePasswordTF setValue:[UIFont systemFontOfSize:16 * LAYOUT_SIZE] forKeyPath:@"_placeholderLabel.font"];
    [self.nePasswordTF setValue:ColorHexA(0xFFFFE0, 0.7) forKeyPath:@"_placeholderLabel.textColor"];
    [self.changeBackView addSubview:self.nePasswordTF];
    
    self.errorButton1 = [[UIButton alloc]initWithFrame:CGRectMake(285 * LAYOUT_SIZE, 125 * LAYOUT_SIZE_HEIGHT,20 * LAYOUT_SIZE , 20 * LAYOUT_SIZE_HEIGHT)];
    self.errorButton1.hidden = YES;
//    self.errorButton1.backgroundColor = [UIColor redColor];
    [self.changeBackView addSubview:self.errorButton1];
    
    self.reImageView = [[UIImageView alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 165 * LAYOUT_SIZE_HEIGHT, 260 * LAYOUT_SIZE, 40 * LAYOUT_SIZE_HEIGHT)];
    self.reImageView.image = [UIImage imageNamed:@"phoneNumberBackGroundInput@2x"];
    [self.changeBackView addSubview:self.reImageView];
    
    self.rePasswordTF = [[UITextField alloc]initWithFrame:CGRectMake(25 * LAYOUT_SIZE, 170 * LAYOUT_SIZE_HEIGHT, 250 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    self.rePasswordTF.placeholder = @"确认密码";
    self.rePasswordTF.secureTextEntry = YES;
    self.rePasswordTF.clearButtonMode = 3;
    [self.rePasswordTF setValue:[UIFont systemFontOfSize:16 * LAYOUT_SIZE] forKeyPath:@"_placeholderLabel.font"];
    [self.rePasswordTF setValue:ColorHexA(0xFFFFE0, 0.7) forKeyPath:@"_placeholderLabel.textColor"];
    [self.changeBackView addSubview:self.rePasswordTF];
    
    self.errorButton2 = [[UIButton alloc]initWithFrame:CGRectMake(285 * LAYOUT_SIZE, 175 * LAYOUT_SIZE_HEIGHT, 20 * LAYOUT_SIZE, 20 * LAYOUT_SIZE_HEIGHT)];
//    self.errorButton2.backgroundColor = [UIColor redColor];
    self.errorButton2.hidden = YES;
    [self.changeBackView addSubview:self.errorButton2];
    
    self.cancleButton3 = [[UIButton alloc]initWithFrame:CGRectMake(20 * LAYOUT_SIZE, 220 * LAYOUT_SIZE_HEIGHT, 130 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    [self.cancleButton3 setTitle:@"取消" forState:UIControlStateNormal];
    self.cancleButton3.backgroundColor = ColorHex(0x90EE90);
    self.cancleButton3.layer.masksToBounds = YES;
    self.cancleButton3.layer.cornerRadius = 8;
    self.cancleButton3.titleLabel.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    [self.changeBackView addSubview:self.cancleButton3];
    
    self.saveButton3 = [[UIButton alloc]initWithFrame:CGRectMake(170 * LAYOUT_SIZE, 220 * LAYOUT_SIZE_HEIGHT, 130 * LAYOUT_SIZE, 30 * LAYOUT_SIZE_HEIGHT)];
    [self.saveButton3 setTitle:@"保存" forState:UIControlStateNormal];
    self.saveButton3.backgroundColor = ColorHex(0x90EE90);
    self.saveButton3.layer.masksToBounds = YES;
    self.saveButton3.layer.cornerRadius = 8;
    self.saveButton3.titleLabel.font = [UIFont systemFontOfSize:17 * LAYOUT_SIZE];
    [self.changeBackView addSubview:self.saveButton3];

    self.errorImageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(240 * LAYOUT_SIZE, 85 * LAYOUT_SIZE_HEIGHT, 0, 0)];
    self.errorImageView1.image = [UIImage imageNamed:@"password"];
    [self.changeBackView addSubview:self.errorImageView1];
    
    self.errorImageView2 = [[UIImageView alloc]initWithFrame:CGRectMake(240 * LAYOUT_SIZE, 135 * LAYOUT_SIZE_HEIGHT, 0, 0)];
    self.errorImageView2.image = [UIImage imageNamed:@"repassword"];
    [self.changeBackView addSubview:self.errorImageView2];
}
@end
